import { Component, OnInit } from '@angular/core';
import { InfiniteScrollCustomEvent } from '@ionic/angular';
import * as Parse from "parse"
(Parse as any).serverURL = "http://metapunk.cn:9999/parse"
Parse.initialize("dev")
@Component({
  selector: 'app-tab-switcher',
  templateUrl: './tab-switcher.component.html',
  styleUrls: ['./tab-switcher.component.scss']
})
export class TabSwitcherComponent implements OnInit{
  ngOnInit(): void {
    this.generateCard();
  }
  activeTab: number = 0;
  
  MediumData: any = []
  text: string[] = [];
  switchTab(tabIndex: number): void {
    this.activeTab = tabIndex;
    console.log(this.activeTab)

  }
  async generateCard() {
    console.log("查询"
    )
      let query = new Parse.Query("BRBMedium");
      query.limit(10)
      query.include("user")
      let mediumList: any = await query.find();
      Array.prototype.push.apply(this.MediumData, mediumList);
      this.text = []
      for (let medium of this.MediumData) {
        this.text.push(medium.get('text'))
      }
  }
  onIonInfinite(ev: any) {
    this.generateCard();
    setTimeout(() => {
      (ev as InfiniteScrollCustomEvent).target.complete();
    }, 300);
  }
}

